<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>数组反转</title>
	</head>
	<body>
		<p id="demo">单击按钮将数组反转排序。</p>
		<button onclick="myFunction()">点我</button>
		<script>
			function myFunction(){
			var fruits=["banana","orange","apple","mango"];
			for(var i=0;i<fruits.length;i++){
				for(var j=1;j<fruits.length-i;j++){
					var t=fruits[j-1];
					fruits[j-1]=fruits[j];
					fruits[j]=t;
				}
			}
			for(var i=0;i<fruits.length;i++){
				document.write("<br />");
				document.write(fruits[i]);
				
			}
			}
		</script>
	</body>
</html>